import WebVideoCreator, { VIDEO_ENCODER, logger } from "./index.js";

async function generateUltraHDVideo() {
    const wvc = new WebVideoCreator();

    // 超高清配置
    wvc.config({
        frameFormat: "png",          // 无损PNG
        frameQuality: 95,            // 最高质量
        browserUseGPU: true,         // GPU加速
        mp4Encoder: VIDEO_ENCODER.CPU.H264,
        debug: true
    });

    const video = wvc.createSingleVideo({
        content: `
        <!DOCTYPE html>
        <html>
        <head>
            <style>
                body { 
                    margin: 0; 
                    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1);
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    height: 100vh;
                    font-family: Arial, sans-serif;
                }
                .container {
                    text-align: center;
                    background: rgba(255,255,255,0.1);
                    padding: 60px;
                    border-radius: 30px;
                    backdrop-filter: blur(20px);
                    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
                }
                h1 {
                    font-size: 72px;
                    color: white;
                    text-shadow: 3px 3px 6px rgba(0,0,0,0.5);
                    margin: 0;
                    animation: glow 3s ease-in-out infinite alternate;
                }
                .subtitle {
                    font-size: 36px;
                    color: rgba(255,255,255,0.9);
                    margin-top: 20px;
                    animation: fadeIn 2s ease-in;
                }
                @keyframes glow {
                    from { text-shadow: 3px 3px 6px rgba(0,0,0,0.5); }
                    to { text-shadow: 3px 3px 20px rgba(255,255,255,0.8); }
                }
                @keyframes fadeIn {
                    from { opacity: 0; transform: translateY(30px); }
                    to { opacity: 1; transform: translateY(0); }
                }
                .circle {
                    width: 200px;
                    height: 200px;
                    border: 5px solid rgba(255,255,255,0.3);
                    border-radius: 50%;
                    position: absolute;
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                    animation: rotate 10s linear infinite;
                }
                @keyframes rotate {
                    from { transform: translate(-50%, -50%) rotate(0deg); }
                    to { transform: translate(-50%, -50%) rotate(360deg); }
                }
            </style>
        </head>
        <body>
            <div class="circle"></div>
            <div class="container">
                <h1>超高清测试</h1>
                <div class="subtitle">1080p @ 60fps</div>
            </div>
        </body>
        </html>
        `,
        
        // 超高清设置
        width: 1920,             // 1080p宽度
        height: 1080,            // 1080p高度
        fps: 60,                 // 60fps
        duration: 10000,         // 10秒
        
        // 质量设置 - 关键！
        videoBitrate: "30000k",  // 30Mbps超高码率
        pixelFormat: "rgb24",    // 最佳颜色
        audioBitrate: "320k",    // 高质量音频
        
        outputPath: "./ultra-hd-test.mp4",
        showProgress: true,
        consoleLog: true
    });

    logger.info("🚀 开始生成超高清视频...");
    
    const result = await video.startAndWait();
    
    logger.success(`✅ 超高清视频生成完成！
📹 分辨率: 1920x1080 @ 60fps
💾 码率: 30Mbps
📁 文件: ./ultra-hd-test.mp4
⏱️  耗时: ${Math.floor(result.takes / 1000)}秒`);
    
    return result;
}

// 运行测试
generateUltraHDVideo().catch(console.error);